home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / mfb / mfbfont.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-15  |  3.0 KB  |  92 lines

  1. /*
  2. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  3. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  4.  
  5.                         All Rights Reserved
  6.  
  7. Permission to use, copy, modify, and distribute this software and its 
  8. documentation for any purpose and without fee is hereby granted, 
  9. provided that the above copyright notice appear in all copies and that
  10. both that copyright notice and this permission notice appear in 
  11. supporting documentation, and that the names of Digital or MIT not be
  12. used in advertising or publicity pertaining to distribution of the
  13. software without specific, written prior permission.  
  14.  
  15. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  16. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  17. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  18. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  19. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  20. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21. SOFTWARE.
  22.  
  23. */
  24. /* $XConsortium: mfbfont.c,v 1.16 89/03/18 12:28:12 rws Exp $ */
  25. #include "X.h"
  26. #include "Xmd.h"
  27. #include "Xproto.h"
  28. #include "fontstruct.h"
  29. #include "dixfontstr.h"
  30. #include "scrnintstr.h"
  31.  
  32. #include "mfb.h"
  33.  
  34. /*
  35.  * Take advantage of the per-screen private information field in the font to
  36.  * encode the results of fairly complex tests of the font's metric fields.
  37.  * ValidateFont need merely examine the code to select the output routines to
  38.  * be pointed to in the GC.
  39.  */
  40. Bool
  41. mfbRealizeFont( pscr, pFont)
  42.     ScreenPtr    pscr;
  43.     FontPtr    pFont;
  44. {
  45.     /*
  46.      * pGC->font is now known to be valid
  47.      */
  48.     int            index = pscr->myNum;
  49.     FontInfoPtr        pfi = pFont->pFI;
  50.     CharInfoPtr        maxb = &pfi->maxbounds;
  51.     CharInfoPtr        minb = &pfi->minbounds;
  52.  
  53.     /*
  54.      * pick the fastest output routines that can do the job.
  55.      */
  56.     if (   maxb->metrics.rightSideBearing -
  57.            minb->metrics.leftSideBearing > 32    /* big glyphs */
  58.       || pfi->drawDirection != FontLeftToRight
  59.       || pfi->noOverlap == 0)
  60.     pFont->devPriv[ index] = (pointer)FT_VARPITCH;
  61.     else  /* an optimizable case */
  62.     {
  63.     if (     maxb->metrics.leftSideBearing ==
  64.             minb->metrics.leftSideBearing /* fixed pitch */
  65.           && maxb->metrics.leftSideBearing == 0      /* fixed pitch */
  66.           && maxb->metrics.rightSideBearing ==
  67.                 minb->metrics.rightSideBearing /* fixed pitch */
  68.           && maxb->metrics.characterWidth ==
  69.                 minb->metrics.characterWidth  /* fixed pitch */
  70.           && maxb->metrics.ascent ==
  71.                 minb->metrics.ascent      /* fixed height */
  72.           && maxb->metrics.descent ==
  73.                 minb->metrics.descent)  /* fixed height */
  74.         pFont->devPriv[ index] = (pointer)FT_FIXPITCH;
  75.     else
  76.         pFont->devPriv[ index] = (pointer)FT_SMALLPITCH;
  77.     }
  78.     return (TRUE);
  79. }
  80.  
  81. /*
  82.  * no storage allocated in mfbRealizeFont, so there is nothing to do
  83.  */
  84. /*ARGSUSED*/
  85. Bool
  86. mfbUnrealizeFont( pscr, pFont)
  87.     ScreenPtr    pscr;
  88.     FontPtr    pFont;
  89. {
  90.     return (TRUE);
  91. }
  92.